/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.muni.fi.pa165.sme.dao.entity;


import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

import cz.muni.fi.pa165.sme.dao.api.PersistentEntity;

/**
 *
 * @author Martin
 */
@Entity
@Table(name = "sport_activity")
@NamedQueries({
    @NamedQuery(name = SportActivity.SELECT_BY_TITLE, query = "SELECT sa from SportActivity sa WHERE sa.title = :title"),
    @NamedQuery(name = SportActivity.SELECT_ALL, query = "select sa from SportActivity sa")
})
public class SportActivity implements PersistentEntity, Serializable {
    
    public static final String SELECT_BY_TITLE = "sa.selectByTitle";
    public static final String SELECT_ALL = "sa.selectAll";
    
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    
    @Column(name = "title")
    private String title;
    
    @Column(name = "speed")
    private Float speed;
    
    public Long getId() {
        return id;
    }

    public void setId(final Long id) {
        this.id = id;
    }
    
    public String getTitle() {
        return title;
    }
    
    public void setTitle(final String title) {
        this.title = title;
    }
    
    public Float getSpeed() {
        return speed;
    }
    
    public void setSpeed(final Float speed) {
        this.speed = speed;
    }
    
    @Override
    public boolean equals(final Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        final SportActivity that = (SportActivity) o;

        if (id != null ? !id.equals(that.id) : that.id != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        return id != null ? id.hashCode() : 0;
    }

    @Override
    public String toString() {
        return "SportActivity{" +
            "id=" + id +
            ", title=" + title +
            ", speed=" + speed +
            '}';
    }
    
}
